package cn.kgc.service;

import cn.kgc.mapper.ProviderMapper;
import cn.kgc.pojo.Provider;
import cn.kgc.pojo.User;
import cn.kgc.util.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 蒿雨
 * @create 2021-11-04 14:35
 */
@Service("psi")
public class ProviderServiceImpl implements ProviderService {
    @Resource
    ProviderMapper providerMapper;

    @Override
    public int getTotalCount(Map<String,Object> map) {
        return providerMapper.getCount(map);
    }

    @Override
    public PageBean<Provider> getProviderList(Map<String, Object> map) {
        PageBean<Provider> pageBean = new PageBean<>();
        pageBean.setPageSize((int) map.get("pageSize"));
        pageBean.setCurrentPage((int) map.get("startIndex"));
        pageBean.setTotalCount(providerMapper.getCount(map));
        map.put("startIndex",pageBean.getStartIndex());
        pageBean.setResult(providerMapper.providerSelect(map));
        return pageBean;
    }

    @Override
    public boolean addProvider(Provider provider) {
        if (providerMapper.addProvider(provider) > 0) {
            return true;
        }
        return false;
    }

    @Override
    public Provider getP(int id) {
        return providerMapper.getProvider(id);
    }

    @Override
    public boolean isFull(int id) {
        if (providerMapper.isFull(id)<=0){
            return true;
        }
        return false;
    }

    @Override
    public int delete(int id) {
        return providerMapper.deleteP(id);
    }

    @Override
    public boolean providerModify(Provider provider) {
        if (providerMapper.providerModify(provider)>0){
            return true;
        }
        return false;
    }

    @Override
    public List<Provider> PROVIDERS() {
        return providerMapper.PROVIDERS();
    }
}
